package cn.bone.server.news.dao;

import org.springframework.stereotype.Repository;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

/**
 * Created by superbone on 2017/3/27.
 */
@Repository
public class JedisDao {

    @Resource
    private JedisPool pool;

    public String getString(String key){

        Jedis jedis = pool.getResource();
        String value = jedis.get(key);
        jedis.close();
        return value;
    }

    public void setString(String key,String value){
        Jedis jedis = pool.getResource();
        jedis.set(key,value);
        jedis.close();
    }

    public void setStringEX(String key,String value,int second){
        Jedis jedis = pool.getResource();
        jedis.setex(key,second,value);
        jedis.close();
    }
}
